package com.xhj.xmly.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

/**
 * Created by XHJ on 2016/12/7.
 */
public class ImageAdapter extends PagerAdapter {
    private List<ImageView> imagesList;

    public ImageAdapter(List<ImageView> imagesList) {
        this.imagesList = imagesList;
    }

    @Override
    public int getCount() {

        return imagesList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(imagesList.get(position));
        return imagesList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(imagesList.get(position));
    }
}
